home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 22 / Amiga Format AFCD22 (Jan 1998, Issue 106).iso / -in_the_mag- / converters / graphics / netpbm / ppmtoinfo / ppmtoinfo.doc < prev    next >
Text File  |  1997-11-16  |  4KB  |  117 lines

  1. PPMTOINFO
  2.  
  3.     COPYRIGHT 1994 Michael W. Heinz, Sr.  All Rights Reserved.
  4.     This application is freely distributable, provided that all 
  5.     documentation is included.
  6.  
  7. Introduction:
  8.  
  9.     One of my all time favorite utilities was "iconize".  Written in 1990,
  10.     iconize would read an ILBM image and scale it into an Amiga WB icon.
  11.     Unfortunately, it only used one palette - and if your WB didn't use it, 
  12.     the icons would look very strange.
  13.  
  14.     I'm also a big fan of the PBM/PPM set of tools.  These tools, written 
  15.     for UNIX systems are easily ported to the Amiga and provide some 
  16.     powerful image conversion and processing tools, even if they have 
  17.     absolutely no user interface.
  18.  
  19.     Combining these two ideas, I came up with PPMTOINFO.  PPMTOINFO 
  20.     converts a PPM formatted image into a WorkBench icon file.  For it to be 
  21.     useful, you will also need the ppm tools (the latest version is called 
  22.     "netpbm" and can be found on the aminet.)
  23.  
  24. Usage:
  25.  
  26.     ppmtoinfo [-tool {default tool}] 0[-tooltype {tool type}]10 
  27.                 -map {mapfile} -icon {iconfile} [{ppmfile}]
  28.  
  29.     In it's simplest form, ppmtoinfo takes three arguments - the name of 
  30.     the ppm file to convert, the name of the ppm file holding the palette 
  31.     and the name of the icon to create.  (.info will be added to the name 
  32.     automagically.)
  33.  
  34.     If -tool is provided, it will be used to set the default tool of the 
  35.     icon. If one or more -tooltype records are provided, they can be used 
  36.     to set the tool types of the icon.  Up to 10 -tooltype records are 
  37.     supported.
  38.  
  39.     The ppmfile (the image to be converted) should be in the P6 format 
  40.     used by standard ppm commands.  It should be scaled to the desired 
  41.     size of the icon, because the icon will be the same size as the 
  42.     original image.  If the ppmfile is not specified in the command line,
  43.     it will be read from the standard input.  This conforms to the usual
  44.     operation of a PPM utility.
  45.  
  46.     The map file is needed because all PPM images are "true color" - they 
  47.     don't use palettes.  The map file is defined in the P3 format and shows 
  48.     the palette, 1 pixel per color.  For example, here is the palette for a 
  49.     standard MagicWB arrangement:
  50.  
  51.     P3
  52.     8 1
  53.     255 
  54.     144 144 144
  55.     0 0 0 
  56.     240 240 240
  57.     80 112 160
  58.     128 128 128
  59.     160 160 160
  60.     160 144 128
  61.     224 160 144
  62.  
  63.     Notice that the colors go from 0 to 255, rather than from 0 to 16.  
  64.     Just multiply your regular palette by 16.  Note also that the palette 
  65.     must include every color present in the original image.  ppmtoinfo 
  66.     makes no attempt to dither or remap the original image - it just 
  67.     translates it into a .info file.  (You'll see why in a minute.)
  68.  
  69.     Typically, you will use this tool in combination with other ppm utilities 
  70.     and tools (For example, djpeg converts jpg images to ppm format.)
  71.  
  72.     So say I wanted to create an icon for a jpg file called "dragonglass".  
  73.     I would perform the following steps:
  74.  
  75.     1.    Convert the jpg to a ppm file:                
  76.                 djpeg dragonglass.jpg dg.ppm
  77.     2.    Scale the ppm file to icon size:
  78.                 pnmsize -xsize 64 dg.ppm >small.ppm
  79.     
  80.         (note that I only specify the size in the x axis.  This allows 
  81.         pnmsize to scale the y axis mathematically to give the icon
  82.         the same appearance as the original image.)
  83.     
  84.     3.    Recolor the ppm file to match your WorkBench:
  85.                 ppmquant -fs -map wb_map.ppm small.ppm >icon.ppm
  86.     
  87.     4.    Convert the ppm file to an icon:
  88.                 ppmtoinfo <icon.ppm -map wb_map.ppm -icon DragonGlass.jpg \
  89.                         -tool RetinaDisplay
  90.  
  91.     The result will be a new icon called "DragonGlass.jpg.info".  Note that
  92.     the palette file used in step 4 is the same one used to re-color the
  93.     image in step 3.  This is why ppmtoinfo doesn't provide built-in 
  94.     recoloring or dithering capabilities - ppmquant already does an
  95.     excellent job.
  96.  
  97.     To simplify the conversion process, you can use the following script,
  98.     which converts iff images to icons of the same name:
  99.  
  100.     MAKEICON
  101.     
  102.     .key file/a,opt/f
  103.     .bra {
  104.     .ket }
  105.  
  106.     echo "Converting {file} to an icon.  Opts: {opt}"
  107.     run ilbmtoppm "{file}" >pipe:mi_a
  108.     run pnmscale >pipe:mi_b -xsize 64 pipe:mi_a
  109.     run ppmquant >pipe:mi_c -fs -map pbm:wb_map.ppm pipe:mi_b
  110.     ppmtoinfo <pipe:mi_c {opt} -map pbm:wb_map.ppm -icon "{file}" 
  111.  
  112.     You can use the "SPAT" script (found in your s: directory) to automatically
  113.     build icons for all the images in a directory.  For example:
  114.     
  115.     SPAT makeicon ~(#?.info) -tool RetinaDisplay
  116.     
  117.